home *** CD-ROM | disk | FTP | other *** search
- REBOL [
- Title: "Birthdays"
- Date: 1998/12/30
- File: %birthdays.r
- Version: 1.0
- Purpose: "Send Birthday Greetings to your friends"
- ]
-
- birthdays: make object!
- [
- choice: 1
-
- loadFriends: make function! []
- [
- if (exists? %friends.dat) [ friends: load %friends.dat ]
- else friends: []
- ]
-
- displayMenu: make function! []
- [
- print ""
- print " Welcome to our little birthday Reminder"
- print " Make your choice:"
- print ""
- print " 1 - Add friend"
- print " 2 - Delete friend"
- print " 3 - Show friends"
- print " 4 - Check Dates"
- print ""
- print " 0 - Save and Exit"
- print ""
- prin " Choice: "
- ]
-
- addFriend: make function! [fr]
- [
- print ""
- print "Add a friend:"
- print ""
- prin "Name : "
- name: make string! input
- prin "Surname : "
- surname: make string! input
- prin "e-mail : "
- email: make email! input
- prin "Birthday: "
- birthday: make date! input
- print""
-
- insert tail fr make block! [name surname email birthday]
- ]
-
- deleteFriend: make function! [fr]
- [
- print ""
- print "Delete a friend:"
- print ""
- prin "Friend's e-mail: "
- email: make email! input
- remove/part (skip find fr email -2) 4
- ]
-
- showFriends: make function! [fr]
- [
- print ""
- print " All entries in Database:"
- print ""
- forskip fr 4
- [
- print [" " first fr "" second fr "" third fr "" fourth fr]
- ]
- ]
-
- checkDates: make function! [fr]
- [
- print ""
- print " Checking for birthdays today..."
- print ""
- today: make date! reduce [first now second now third now]
- forskip fr 4
- [
- birthday: make date! fourth fr
- if ((first birthday) = (first today)) and ((second birthday) = (second today))
- [
- print [second fr "got Birthday!! Sending Birthday Greetings..."]
- send third fr "Happy Birthday"
- print "done!"
- ]
- ]
- ]
-
- MainLoop: make function! []
- [
- loadFriends
- while [choice <> "0"]
- [
- displayMenu []
- choice: input
- if choice = "1" [addFriend friends]
- if choice = "2" [deleteFriend friends]
- if choice = "3" [showFriends friends]
- if choice = "4" [checkDates friends]
- ]
- Store friends
- ]
-
- Check: make function! []
- [
- loadFriends
- checkDates friends
- ]
-
- Store: make function! [fr]
- [
- save %friends.dat fr
- ]
- ]
-